package com.diankangwo.dao.impl;

import com.diankangwo.dao.SearchDAO;
import com.diankangwo.domain.Search;
import com.diankangwo.util.PageSupport;
import org.springframework.stereotype.Repository;

@Repository
public class SearchDAOImpl extends BaseDaoImpl<Search> implements SearchDAO {
    @Override
    public PageSupport<Search> findBySearchInfo(Integer uid, Integer type, String antistop,int pageNo ,int pageSize) {
        PageSupport<Search> searchList = new PageSupport<>();
        String hql = "from Search search where 1 = 1";
        if (type == 1) {
            hql = " and search.type = 1";
            searchList =  findPagination(hql,pageNo,pageSize);
        } else {
            hql = " and search.uid = ? and search.antistop =?";
            searchList =  findPagination(hql,pageNo,pageSize,uid,antistop);
        }
        if (searchList == null || searchList.getResultData().size() ==0) {
            return null;
        }else{
            return searchList;
        }
    }
}
